package com.example.hy2110szyx.service.impl;

import com.example.hy2110szyx.entity.Distribution;
import com.example.hy2110szyx.entity.FlightInfo;
import com.example.hy2110szyx.entity.Route;
import com.example.hy2110szyx.repository.FlightMapper;
import com.example.hy2110szyx.service.FlightService;
import com.example.hy2110szyx.vo.PageVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FlightServiceImpl implements FlightService {

    @Autowired
    private FlightMapper flightMapper;



    @Override
    public FlightInfo queryByFno(String fno) {
        return flightMapper.queryByFno(fno);
    }

    /**
     * 分页查询航班
     * @param pageVo
     * @return
     */
    @Override
    public Page<FlightInfo> queryAllFlightsForPage(PageVo<FlightInfo> pageVo) {
        Page<FlightInfo> page = PageHelper.startPage(pageVo.getStart(), pageVo.getMax(),
                pageVo.getOrderBy() + " " + pageVo.getOrder());
        flightMapper.queryAllConn(pageVo.getCondition());
        return page;
    }

    @Override
    public List<FlightInfo> queryAll() {
        return flightMapper.queryAll();
    }

    @Override
    public List<FlightInfo> queryById(Integer id) {
        return flightMapper.queryById(id);
    }

    @Override
    public void insertOneFlight(FlightInfo flightInfo) {
        flightMapper.insertOneFlight(flightInfo);
    }


    @Override
    public void updateOneFlight(FlightInfo flightInfo) {
        flightMapper.updateOneFlight(flightInfo);
    }


    /**
     * 根据id批量删除航班
     * @param ids
     */
    @Override
    public void deleteSomeById(Integer[] ids) {
        flightMapper.deleteSomeById(ids);
    }





}
